#include <iostream>

using namespace std;

#define MAX_QUEUE_SIZE 20

class Queue 
{
public:
	Queue();
	void deQueue();
	void enQueue(int elem);
	void display();
	
	
private:
	int m_data[MAX_QUEUE_SIZE];
	int m_front;
	int m_end;
};

Queue::Queue()
{
	m_front = -1;
	m_end = -1;
}

void Queue::deQueue()
{
	int tmp;
	if(m_end == -1) {
		cout<<"Queue is empty!"<<endl;
	} else {
		for(int j = 0; j <= m_front; j++) {
			if(j+1 <= m_front) {
				tmp = m_data[j+1];
				m_data[j] = tmp;
			} else {
				m_front--;
				if(m_front == -1)
					m_end = -1;
				else 
					m_end = 0;
			}
		}
	}
}

void Queue::enQueue(int elem)
{
	if(m_front == -1 && m_end == -1) {
		m_front++;
		m_end++;
	} else {
		m_front++;
		if(m_front == MAX_QUEUE_SIZE) {
			cout<< "Queue is full\n";
			m_front--;
			return;
		}
	}
	m_data[m_front] = elem;
	
}

void Queue::display()
{
	if(m_end != -1) {
		for(int iter = 0; iter <= m_front; iter++) {
			cout<<m_data[iter]<<" ";
		}
	} else {
		cout<<"Empty Queue\n";
	}
}

int main()
{
	Queue queue;
	int data[5] = {32,23,45,88,66};
	cout<< "Queue before adding elements:"<<endl;

	queue.display();
	cout<<endl<<endl;

	for(int iter = 0; iter <5; iter++) {
		queue.enQueue(data[iter]);
		cout<<"Addintion Number : "<<iter+1 << " : ";
		queue.display();
		cout<<endl;
	}

	cout<<endl;
	cout<<"queue after addition"<<endl;
	queue.display();

	cout<<endl;
	cout<<endl;
	
	for(int i = 0; i <5; i++) {
		queue.deQueue();
		cout<<"Deleting Number : "<<i+1<<" : ";
		queue.display();
		cout<<endl;
	}

	return 0;
}
